package com.xoa.controller.knowledge;


import com.xoa.model.knowledge.KnowledgeCustomer;
import com.xoa.model.knowledge.KnowledgeDocfile;
import com.xoa.model.knowledge.KnowledgeSubscribe;
import com.xoa.service.knowledge.SubscribeService;
import com.xoa.util.LimsJson;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/subscribe")
public class SubscribeController {

    @Autowired
    private SubscribeService subscribeService;


    //栏目订阅页面
    @RequestMapping("/getColumManagePage")
    public String getColumManagePage() { return "/app/knowledge/columnSubscription/columnsub"; }

    //栏目订阅页面
    @RequestMapping("/subappro")
    public String subscription() { return "/app/knowledge/subscriptionApproval/subappro"; }

    //栏目订阅页面
    @RequestMapping("/showSubapproInfo")
    public String showSubapproInfo() { return "/app/knowledge/subscriptionApproval/showSubapproInfo"; }

    /**
     *
     * @作者 李卫卫
     * @创建日期 15:14 2020/9/14
     * @类介绍 添加客户文档订阅
     * @参数
     * @return limsJson
     */

    @RequestMapping("/insertSelective")
    @ResponseBody
    public LimsJson insertSelective(HttpServletRequest request,KnowledgeSubscribe record) {
        return subscribeService.insertSelective(request,record);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 15:14 2020/9/14
     * @类介绍  删除客户文档订阅
     * @参数
     * @return limsJson
     */

    @RequestMapping("/deleteByPrimaryKey")
    @ResponseBody
    public LimsJson deleteByPrimaryKey(Integer subscribeId) {
        return subscribeService.deleteByPrimaryKey(subscribeId);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 16:13 2020/9/14
     * @类介绍  编辑客户文档订阅
     * @参数
     * @return limsJson
     */

    @RequestMapping("/update")
    @ResponseBody
    public LimsJson update(KnowledgeSubscribe record) {
        return subscribeService.update(record);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 10:50 2020/9/15
     * @类介绍   查看订阅用户信息
     * @参数
     * @return limsJson
     */

    @RequestMapping("/selectByCustomerId")
    @ResponseBody
    public LimsJson selectByCustomerId(Integer customerId) {
        return subscribeService.selectByCustomerId(customerId);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 13:58 2020/9/15
     * @类介绍
     * @参数
     * @return limsJson
     */
    @RequestMapping("/selectByList")
    @ResponseBody
    public LimsJson selectByList(HttpServletRequest request) {
        return subscribeService.selectByList( request);
    }

    /**
     *
     * @作者 李卫卫
     * @创建日期 15:56 2020/9/16
     * @类介绍  查询订阅数据
     * @参数
     * @return limsJson
     */

    @RequestMapping("/getSubscription")
    @ResponseBody
    public LimsJson getSubscription() {
        return subscribeService.getSubscription();
    }

    /**
     * 王辰
     * 栏目订阅搜索
     *
     *
     */
    @RequestMapping("/search")
    @ResponseBody
    public LimsJson search(HttpServletRequest request , KnowledgeDocfile KnowledgeDocfile,Integer page,Integer limit){
        return subscribeService.search(request,KnowledgeDocfile,page,limit);
    }


    /**
     * 根据文档id查询所有该客户的订阅历史
     *
     */
    @RequestMapping("/getOldByFildAndCustomer")
    @ResponseBody
    public LimsJson getOldByFildAndCustomer(HttpServletRequest request ,Integer customerId,Integer fileId,Integer page,Integer limit){
        return subscribeService.getOldByFildAndCustomer(request,customerId,fileId,page,limit);
    }


    //导出功能 文件管理 导出用户导出文件
    @RequestMapping("/getFileExport")
    @ResponseBody
    public LimsJson getFileExport(HttpServletRequest request, HttpServletResponse response, KnowledgeDocfile knowledgeDocfile) {
        return subscribeService.getFileExport(request,response,knowledgeDocfile);
    }

    /**
     * 客户订阅一栏，查看所有客户所有订阅文档
     * @param customer
     * @return
     */
    @RequestMapping("/getCustomerAndFile")
    @ResponseBody
    public ToJson getCustomerAndFile(HttpServletRequest request,KnowledgeCustomer customer, Integer page, Integer limit,String isSysCode){
        return subscribeService.getCustomerAndFile(request,customer,page,limit,isSysCode);
    }
}
